package com.mo.math;

import java.util.Scanner;

/**
 * @ClassName MaxCommonDivisor
 * @Description 求最大公约数
 * @Author Administrator
 * @Date 2021/8/3
 * @Version 1.0
 */
public class MaxCommonDivisor {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int j = scanner.nextInt();

        int temp = commonDivisor(Math.max(i, j), Math.min(i, j));
        System.out.print(i + " 与 " + j);
        System.out.println(" 的大公约数为：" + temp);
    }

    public static int commonDivisor(int i, int j) {
        int temp = 0;
        while (i != j) {
            int a = i;
            int b = j;
            i = Math.max(b, a - b);
            j = Math.min(b, a - b);

            if (i == j) {
                temp = i;
                break;
            }
        }
        return temp;
    }
}
